//
//  LKAddWorkCustomViewController.m
//  YLHelper
//
//  Created by she1323 on 2018/5/7.
//  Copyright © 2018年 she1323. All rights reserved.
//

#import "LKAddWorkCustomViewController.h"
#import "LKWorkOrderListDetailCell.h"
#import "LKWorkOrderListDetailPictureCell.h"
#import "LKWorkOrderDetailPOSPicCell.h"
#import "LKWorkOrderDetailOtherPicCell.h"
#import "LKAddProtocalMessageCell.h"
#import "LKWorkOrderDetailContractCell.h"
#import "LKPickeCustomView.h"
#import "LKAddBankCardViewController.h"
#import "GFAddressPicker.h"
#import "LKAddCustomerModel.h"
#import "LKPictureDeleteOrAddCell.h"
#import "HXPhotoPicker.h"
#import "LKPictureDeleteOrAddModel.h"
#import "LKBankFoldCell.h"
#import "LKCustomerAttachModel.h"
#import "HXPhotoManager.h"
#import "HXPhotoTools.h"
#import "LKUpLoadChangeFileView.h"
#import "LKWorkViewController.h"
#import "LKReservePhoneNumberCell.h"
#import "AppDelegate.h"
@interface LKAddWorkCustomViewController ()<UITableViewDataSource,UITableViewDelegate,GetContentInformation,GFAddressPickerDelegate,UIImagePickerControllerDelegate,UIViewControllerTransitioningDelegate,UINavigationControllerDelegate>
@property(nonatomic,strong)LKBaseTableview *tableview;
@property(nonatomic,strong)NSArray *headerTitlsArray;
@property(nonatomic,strong)NSArray *headerIconsArray;
@property(nonatomic,strong)NSMutableArray *cellContentArray;
@property(nonatomic,assign)BOOL bankFlag;
@property(nonatomic,assign)BOOL secondbankFlag;
@property(nonatomic,strong)LKPickeCustomView *pickerView;
@property(nonatomic,strong)LKPickeCustomView *sorcepickerView;
@property(nonatomic,strong)LKPickeCustomView *relationView;
@property(nonatomic,strong)LKPickeCustomView *visitPhoneView;
@property(nonatomic,strong)GFAddressPicker *addpickerView;
@property(nonatomic,strong)LKAddCustomerModel *model;
@property(nonatomic,assign)NSInteger selectValue;
@property (strong, nonatomic) HXDatePhotoToolManager *toolManager;
@property (strong, nonatomic) HXPhotoManager *manager;
@property(strong,nonatomic) LKPictureDeleteOrAddModel *picsModel;
@property (strong, nonatomic) NSMutableArray *picdataArray;
@property(nonatomic,strong)NSMutableArray *bankListArray;
@property(nonatomic,strong)LKBankModel *bankModel;
@property(nonatomic,strong)NSMutableArray *showBankCardArray;
@property(nonatomic,strong)NSMutableArray *attachsArray;
@property(nonatomic,strong)NSMutableArray *uploadImageArray;
@property(nonatomic,assign)BOOL tmdFirstShow;
@property(nonatomic,assign)BOOL tmdSecondShow;
@property(nonatomic,assign)BOOL tmdThirdShow;
@property(nonatomic,assign)BOOL tmdFourthShow;
@property(nonatomic,assign)BOOL tmdlajiShow;
@property(nonatomic,strong)LKUpLoadChangeFileView *uploadChangeFileView;
@property(nonatomic,strong)UIView *uploadBgView;
@property(nonatomic,strong)NSMutableArray *customerAttachsChangeArray;
@property(nonatomic,assign)BOOL waitSignal;
@property(nonatomic,copy)NSString *selectbtnTitle;

@end

@implementation LKAddWorkCustomViewController
- (HXDatePhotoToolManager *)toolManager {
    if (!_toolManager) {
        _toolManager = [[HXDatePhotoToolManager alloc] init];
    }
    return _toolManager;
}
-(LKAddCustomerModel *)model{
    if (!_model) {
        _model = [[LKAddCustomerModel alloc] init];
        
//        _model.IdentitfyCategory = @"1";
    }
    return _model;
}
-(LKBaseTableview *)tableview{
    if (!_tableview) {
        _tableview = [LKBaseTableview setTableviewWithFrame:CGRectMake(0, NAVIGATION_BAR_HEIGHT + 10, WIDTH , HEIGHT - NAVIGATION_BAR_HEIGHT - 10) style:UITableViewStyleGrouped registercellClasss:@[@"LKWorkOrderListDetailCell",@"LKWorkOrderListDetailPictureCell",@"LKWorkOrderDetailOtherPicCell",@"LKAddProtocalMessageCell",@"LKWorkOrderDetailContractCell",@"LKBankFoldCell",@"LKReservePhoneNumberCell"]];
        [_tableview registerClass:[LKPictureDeleteOrAddCell class] forCellReuseIdentifier:@"LKPictureDeleteOrAddCell"];
//        [self.view addSubview:_tableview];
        _tableview.delegate = self;
        _tableview.dataSource = self;
    }
    return _tableview;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.waitSignal = YES;
    self.tmdFirstShow = NO;
    self.tmdFirstShow = NO;
    self.tmdFirstShow = NO;
    self.tmdFirstShow = NO;
    self.tmdlajiShow = NO;
    self.picdataArray = [NSMutableArray array];
    self.model.IdentitfyCategory = @"1";
    self.model.IsAuthenticated = @"1";
    //数据源的初始设置
    if ([self.model.IdentitfyCategory isEqual:@"1"]) {
        if ([self.model.IsAuthenticated boolValue]) {
            self.cellContentArray = [[NSMutableArray alloc] initWithArray:@[@[@"姓名：",@"证件类型：",@"证件号码：",@"性别：",@"邮箱：",@"所在地区：",@"详细地址：",@"来源："],self.showBankCardArray,@[@""],@[@"姓名：",@"电话：",@"关系："],@[@""]]];
            self.headerTitlsArray = @[@"基本信息",@"银行信息",@"默认回访手机号",@"紧急联系人",@"附件信息"];
            self.headerIconsArray = @[@"xieyixinxi",@"yinhangxinxi",@"defautVistiPhone",@"customerHeaderIcon",@"fujian"];
        }else{
            self.cellContentArray = [[NSMutableArray alloc] initWithArray:@[@[@"姓名：",@"证件类型：",@"证件号码：",@"电话：",@"性别：",@"邮箱：",@"所在地区：",@"详细地址：",@"来源：",@"证件附件正面：",@"证件附件反面："],self.showBankCardArray,@[@"姓名：",@"电话：",@"关系："],@[@""]]];
            self.headerTitlsArray = @[@"基本信息",@"银行信息",@"紧急联系人",@"附件信息"];
            self.headerIconsArray = @[@"xieyixinxi",@"yinhangxinxi",@"customerHeaderIcon",@"fujian"];
        }

    }else{
        self.cellContentArray = [[NSMutableArray alloc] initWithArray:@[@[@"姓名：",@"证件类型：",@"证件号码：",@"电话：",@"性别：",@"邮箱：",@"所在地区：",@"详细地址：",@"来源：",@"证件附件正面：",@"证件附件反面："],self.showBankCardArray,@[@"姓名：",@"电话：",@"关系："],@[@""]]];
        self.headerTitlsArray = @[@"基本信息",@"银行信息",@"紧急联系人",@"附件信息"];
         self.headerIconsArray = @[@"xieyixinxi",@"yinhangxinxi",@"customerHeaderIcon",@"fujian"];
    }
//    KVO处理
    
    for (int i = 0; i < 4; i++) {
        LKPictureDeleteOrAddModel *model = [[LKPictureDeleteOrAddModel alloc] init];
        [self.picdataArray addObject:model];
    }
    [self.view addSubview:self.tableview];
    if (self.updateType) {
        self.navigationItem.title = [NSString stringWithFormat:@"%@客户",self.headerTitle];
        self.model.IdentitfyCategory = self.updateModel.identitfyCategory;
        [self getUpdateModelInformation];
    }else{
        if (self.isOrderUpdate) {
              self.navigationItem.title = [NSString stringWithFormat:@"%@客户",self.headerTitle];
              [self getUpdateModelInformation];
        }else{
            self.navigationItem.title = @"添加客户";
            [self.tableview reloadData];
        }

    }
    // Do any additional setup after loading the view.
}
-(void)setNavgationBackBtn{
    [super setNavgationBackBtn];
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.titleLabel.font = [UIFont systemFontOfSize:16];
    [btn setTitle:@"保存" forState:UIControlStateNormal];
    if ([self.headerTitle containsString:@"变更"]) {
        [btn setTitle:@"提交" forState:UIControlStateNormal];
    }
    [btn setTitleColor:blueDefault forState:UIControlStateNormal];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    [btn addTarget:self action:@selector(addAndSaveCustomerInformation:) forControlEvents:UIControlEventTouchUpInside];
}

#pragma mark -保存并创建新用户
-(void)addAndSaveCustomerInformation:(UIButton *)btn{
    self.selectbtnTitle = btn.titleLabel.text;
        NSMutableDictionary *dicPara = [[NSMutableDictionary alloc] init];
    if ([self.headerTitle containsString:@"变更"]) {
        if (!self.uploadBgView) {
            self.uploadBgView = [[UIView alloc] initWithFrame:CGRectMake(0, NAVIGATION_BAR_HEIGHT, WIDTH, HEIGHT - NAVIGATION_BAR_HEIGHT)];
            self.uploadBgView.backgroundColor = [UIColor lightGrayColor];
            [self.view addSubview:self.uploadBgView];
            [self.view bringSubviewToFront:self.uploadBgView];
            self.uploadChangeFileView = [[LKUpLoadChangeFileView alloc] initWithFrame:CGRectMake(10, NAVIGATION_BAR_HEIGHT + 30, WIDTH - 20, HEIGHT/3 * 2)];
            self.uploadChangeFileView.backgroundColor = [UIColor whiteColor];
            [self.uploadBgView addSubview:self.uploadChangeFileView];
            UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            [cancelBtn addTarget:self action:@selector(dismissTheUpLoadBgView:) forControlEvents:UIControlEventTouchUpInside];
            [self.uploadBgView addSubview:cancelBtn];
            [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(self.uploadChangeFileView.mas_right);
                make.bottom.equalTo(self.uploadChangeFileView.mas_top).offset(-5);
                make.size.mas_equalTo(CGSizeMake(20, 20));
            }];
            [cancelBtn setImage:[UIImage imageNamed:@"shibai"] forState:UIControlStateNormal];
            [self.uploadChangeFileView.upBtn addTarget:self action:@selector(uploadChangeFileAction:) forControlEvents:UIControlEventTouchUpInside];
        }else{
            [self.view addSubview:self.uploadBgView];
            [self.view bringSubviewToFront:self.uploadBgView];
        }
        
    }
    if (self.updateType) {
        if ([self.headerTitle containsString:@"变更"]) {
            if (self.waitSignal) {
                return;
            }else{
                [self.uploadBgView removeFromSuperview];
                NSDictionary *param = [NSDictionary dictionaryWithObjectsAndKeys:self.customerAttachsChangeArray,@"CustomerAttachChange", nil];
                [dicPara addEntriesFromDictionary:param];
            }
        }else{
            self.waitSignal = NO;
        }
    }else{
        self.waitSignal = NO;
    }
    [self.attachsArray removeAllObjects];
    self.model.IdentitfyPhoto = nil;
    self.model.IdentitfyBackPhoto = nil;
    self.model.AttachImage = nil;
    self.model.AttachUrl = nil;
    self.model.CustormerCategory = @"1";
    if ([self.headerTitle containsString:@"变更"]) {
        self.model.ApprovalStatus = @"1";
    }
    __block LKPictureDeleteOrAddModel *model = self.picdataArray[3];
    
       WS(weakSelf)
    if (model.endSelectedList.count == 0) {
        NSDictionary *param = [weakSelf.model properties_aps];
        NSDictionary *param1 = @{@"BankCards":weakSelf.bankListArray};
        [dicPara addEntriesFromDictionary:param];
        [dicPara addEntriesFromDictionary:param1];
        NSString *chooseUrl;
        if (weakSelf.updateType || weakSelf.isOrderUpdate) {
            NSDictionary *param2;
            if ([self.headerTitle containsString:@"变更"]) {
                chooseUrl = updateCustomerUrl;
            }else{
                chooseUrl = editCustomerUrl;
            }
            if (weakSelf.updateType) {
                param2 = @{@"Id":weakSelf.updateModel.customerId,@"Customercode":weakSelf.updateModel.customerCode,@"Owner":weakSelf.updateModel.owner,@"CustormerCategory":[NSString backTitleAccordingCustormerCategoryType:[weakSelf.updateModel.custormerCategory integerValue]]};
            }else{
                param2 = @{@"Id":weakSelf.addOrderModel.CustomerId,@"Customercode":weakSelf.addOrderModel.CustomerCode,@"Owner":weakSelf.addOrderModel.Owner};
                
            }
            [dicPara addEntriesFromDictionary:param2];
            
            [SVProgressHUD showWithStatus:@"保存中..."];
            [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:chooseUrl header:[LKUserInforTool header] parameters:dicPara progress:^(NSProgress * _Nullable progress) {
                
            } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                [SVProgressHUD dismiss];
                [SVProgressHUD showInfoWithStatus:@"保存成功"];
                [weakSelf.navigationController popToRootViewControllerAnimated:YES];
                
                [[NSNotificationCenter defaultCenter] postNotificationName:@"AddcustomerReloadTableview" object:nil];
                
            } failure:^(NSString * _Nullable errorMessage) {
                
            }];
            
        }else{
            [SVProgressHUD showWithStatus:@"保存中..."];
            [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:addCustomerUrl header:[LKUserInforTool header] parameters:dicPara progress:^(NSProgress * _Nullable progress) {
                
            } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                [SVProgressHUD showInfoWithStatus:@"保存成功"];
                if (weakSelf.isOrderUpdate) {
                    [weakSelf.navigationController popToRootViewControllerAnimated:YES];
                }else{
                    [weakSelf.navigationController popViewControllerAnimated:YES];
                }
                [[NSNotificationCenter defaultCenter] postNotificationName:@"AddcustomerReloadTableview" object:nil];
            } failure:^(NSString * _Nullable errorMessage) {
                
            }];
        }
    }else{
        [self.toolManager getSelectedImageList:model.endSelectedList success:^(NSArray<UIImage *> *imageList) {
            
            weakSelf.attachsArray = imageList.mutableCopy;
            NSMutableArray *uploadImages = [[NSMutableArray alloc] init];
            for (NSInteger i = 0; i < weakSelf.attachsArray.count; i++) {
                UIImage *image = weakSelf.attachsArray[i];
                [[LKNetDataManager defaultManager] sendPOSTRequestWithserverUrl:ServerlUrl apiPath:otherOfPictureUrl parameters:nil imageArray:@[image] targetWidth:100 progress:^(NSProgress * _Nullable progress) {
                    
                } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                    NSMutableDictionary *attachDic = [[NSMutableDictionary alloc] init];
                    attachDic[@"AttachName"] = responseObject[@"fileName"];
                    attachDic[@"AttachUrl"] = responseObject[@"fileUrl"];
                    attachDic[@"Suffix"] = responseObject[@"suffix"];
                    attachDic[@"Id"] = @"0";
                    [uploadImages addObject:attachDic];
                    NSLog(@"fuck=%@",uploadImages);
                    if (uploadImages.count == weakSelf.attachsArray.count) {
                        NSDictionary *param = [weakSelf.model properties_aps];
                        NSDictionary *param1 = @{@"BankCards":weakSelf.bankListArray};
                        NSDictionary *param2 = @{@"CustomerAttach0":uploadImages};
                        [dicPara addEntriesFromDictionary:param];
                        [dicPara addEntriesFromDictionary:param1];
                        [dicPara addEntriesFromDictionary:param2];
                        NSString *chooseUrl;
                        if (weakSelf.updateType || weakSelf.isOrderUpdate) {
                            NSDictionary *param2;
                            if ([self.headerTitle containsString:@"变更"]) {
                                chooseUrl = updateCustomerUrl;
                            }else{
                                chooseUrl = editCustomerUrl;
                            }
                            if (weakSelf.updateType) {
                                param2 = @{@"Id":weakSelf.updateModel.customerId,@"Customercode":weakSelf.updateModel.customerCode,@"Owner":weakSelf.updateModel.owner,@"CustormerCategory":[NSString backTitleAccordingCustormerCategoryType:[weakSelf.updateModel.custormerCategory integerValue]]};
                            }else{
                                param2 = @{@"Id":weakSelf.addOrderModel.CustomerId,@"Customercode":weakSelf.addOrderModel.CustomerCode,@"Owner":weakSelf.addOrderModel.Owner};
                                
                            }
                            [dicPara addEntriesFromDictionary:param2];
                            
                            [SVProgressHUD showWithStatus:@"保存中..."];
                            [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:chooseUrl header:[LKUserInforTool header] parameters:dicPara progress:^(NSProgress * _Nullable progress) {
                                
                            } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                                //                               [SVProgressHUD dismiss];
                                [SVProgressHUD showInfoWithStatus:@"保存成功"];
                                [weakSelf.navigationController popToRootViewControllerAnimated:YES];
                                [[NSNotificationCenter defaultCenter] postNotificationName:@"AddcustomerReloadTableview" object:nil];
                                
                            } failure:^(NSString * _Nullable errorMessage) {
                                
                            }];
                            
                        }else{
                            [SVProgressHUD showWithStatus:@"保存中..."];
                            [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:addCustomerUrl header:[LKUserInforTool header] parameters:dicPara progress:^(NSProgress * _Nullable progress) {
                                
                            } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                                
                                [SVProgressHUD showInfoWithStatus:@"保存成功"];
                                if (self.specialAdd) {
                                    [self dismissViewControllerAnimated:YES completion:nil];
                                    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
                                    
                                    UITabBarController *tabViewController = (UITabBarController *) appDelegate.window.rootViewController;
                                    
                                    [tabViewController setSelectedIndex:1];
                                    UINavigationController *navvc = tabViewController.viewControllers[1];
                                    LKWorkViewController *vc = navvc.viewControllers[0];
                                    
                                    NSLog(@"%@",tabViewController.viewControllers);
                                    NSLog(@"%@",vc.lalala);
                                    [vc.flipView selectIndex:1];
                                    [vc.segment selectIndex:2];
                                  [[NSNotificationCenter defaultCenter] postNotificationName:@"AddcustomerReloadTableview" object:nil];
                                    return ;
                                }

                                if (weakSelf.isOrderUpdate) {
                                    [weakSelf.navigationController popToRootViewControllerAnimated:YES];
                                }else{
                                    [weakSelf.navigationController popViewControllerAnimated:YES];
                                }
                                
                                [[NSNotificationCenter defaultCenter] postNotificationName:@"AddcustomerReloadTableview" object:nil];
                            } failure:^(NSString * _Nullable errorMessage) {
                                
                            }];
                        }
                        
                    }
                } failure:^(NSString * _Nullable error) {
                    
                }];
            }
        } failed:^{
            
        }];
    }
    
 

}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.cellContentArray.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    NSArray *contentsArra = self.cellContentArray[section];
    if ([self.headerTitle containsString:@"变更"]) {
        if ([self.model.IdentitfyCategory isEqual:@"1"]) {
            if ([self.model.IsAuthenticated boolValue]) {
                if (section == 0) {
                    if (self.tmdFirstShow) {
                        return contentsArra.count;
                    }else{
                        return 0;
                    }
                }else if (section == 1){
                    if (self.tmdSecondShow) {
                        return contentsArra.count;
                    }else{
                        return 0;
                    }
                }else if (section == 3){
                    if (self.tmdThirdShow) {
                        return contentsArra.count;
                    }else{
                        return 0;
                    }
                }else if(section == 4){
                    if (self.tmdFourthShow) {
                        return contentsArra.count;
                    }else{
                        return 0;
                    }
                }else{
                    if (self.tmdlajiShow) {
                        return contentsArra.count;
                    }else{
                        return 0;
                    }
                }
            }else{
                if (section == 0) {
                    if (self.tmdFirstShow) {
                        return contentsArra.count;
                    }else{
                        return 0;
                    }
                }else if (section == 1){
                    if (self.tmdSecondShow) {
                        return contentsArra.count;
                    }else{
                        return 0;
                    }
                }else if (section == 2){
                    if (self.tmdThirdShow) {
                        return contentsArra.count;
                    }else{
                        return 0;
                    }
                }else{
                    if (self.tmdFourthShow) {
                        return contentsArra.count;
                    }else{
                        return 0;
                    }
                }

            }
 
        }else{
            if (section == 0) {
                if (self.tmdFirstShow) {
                    return contentsArra.count;
                }else{
                    return 0;
                }
            }else if (section == 1){
                if (self.tmdSecondShow) {
                    return contentsArra.count;
                }else{
                    return 0;
                }
            }else if (section == 2){
                if (self.tmdThirdShow) {
                    return contentsArra.count;
                }else{
                    return 0;
                }
            }else{
                if (self.tmdFourthShow) {
                    return contentsArra.count;
                }else{
                    return 0;
                }
            }
        }

       
    }
    return contentsArra.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    LKWorkOrderListDetailCell *ListDetailcell = [tableView dequeueReusableCellWithIdentifier:@"LKWorkOrderListDetailCell"];
    WS(weakSelf)
    if ([self.model.IdentitfyCategory isEqual:@"1"]) {
        if ([self.model.IsAuthenticated boolValue]) {
            switch (indexPath.section) {
                case 0:
                {
                    //根据证件的类型设置第一部分cell的展示
                    LKAddProtocalMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LKAddProtocalMessageCell"];
                    cell.mustShowStar.hidden = NO;
                    cell.titleLabel.text = self.cellContentArray[indexPath.section][indexPath.row];
                    cell.lineView.hidden = YES;
                    cell.bottomLineView.hidden = NO;
                    cell.pictureImageView.hidden = YES;
                    cell.contentTF.enabled = NO;
                    cell.contentTF.tag = 10000 + indexPath.row;
                    [cell.contentTF addTarget:self action:@selector(changeSectionOneValue:) forControlEvents:UIControlEventEditingChanged];
                    if (indexPath.row == 0 || indexPath.row == 2 || indexPath.row == 4 || indexPath.row == 6) {
                        cell.arrowBtn.hidden = YES;
                        cell.contentTF.placeholder = @"请输入";
                        cell.contentTF.hidden = NO;
                        switch (indexPath.row) {
                            case 0:
                            {
                                cell.contentTF.enabled = YES;
                                cell.lineView.hidden = NO;
                                cell.contentTF.text = self.model.CustomerName;
                            }
                                break;
                            case 2:
                            {
                                cell.contentTF.enabled = YES;
                                cell.contentTF.text = self.model.IdentityId;
                            }
                                break;
                            case 4:
                            {
                                cell.contentTF.enabled = YES;
                                cell.mustShowStar.hidden = YES;
                                cell.contentTF.text = self.model.Email;
                            }
                                break;
                            case 6:
                            {
                                cell.contentTF.enabled = YES;
                                cell.mustShowStar.hidden = YES;
                                cell.contentTF.text = self.model.Address;
                            }
                                break;
                                
                            default:
                                break;
                                return cell;
                        }
                        
                    }else{
                        cell.lineView.hidden = NO;
                        cell.contentTF.placeholder = @"请选择";
                        cell.contentTF.enabled = NO;
                        cell.arrowBtn.hidden = NO;
                        cell.contentTF.hidden = NO;
                        switch (indexPath.row) {
                            case 3:
                            {
                                cell.contentTF.hidden = NO;
                                if ([self.model.CustomerGender isEqual:@"0"]) {
                                    cell.contentTF.text = @"男";
                                }else if([self.model.CustomerGender isEqual:@"1"]){
                                    cell.contentTF.text = @"女";
                                }else{
                                    cell.contentTF.text = @"";
                                }
                            }
                                break;
                            case 1:
                            {
                                cell.contentTF.hidden = NO;
                                cell.contentTF.text = self.model.IdentitfyCategory ? [self backTitleAccordingIdCatogaryType:[self.model.IdentitfyCategory integerValue]] :@"";
                            }
                                break;
                            case 5:
                            {
                                cell.contentTF.hidden = NO;
                                cell.mustShowStar.hidden = YES;
                                cell.contentTF.text = self.model.City;
                            }
                                break;
                            case 7:
                            {
                                cell.contentTF.hidden = NO;
                                cell.mustShowStar.hidden = YES;
                                cell.contentTF.text = self.model.Source ? [self backTitleAccordingSorceType:[self.model.Source integerValue]] : @"";
                            }
                                break;
                            default:
                                break;
                                return cell;
                        }
                        
                    }
                    if (indexPath.row == 9 || indexPath.row == 10) {
                        cell.arrowBtn.hidden = YES;
                        cell.lineView.hidden = YES;
                        cell.pictureImageView.hidden = NO;
                        cell.contentTF.hidden = YES;
                        cell.bottomLineView.hidden = YES;
                        cell.pictureImageView.userInteractionEnabled = YES;
                        if (indexPath.row == 9) {
                            [cell.pictureImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",ServerlUrl,self.model.IdentitfyPhotoUrl]] placeholderImage:[UIImage imageNamed:@"shangchuan"]];
                        }else{
                            [cell.pictureImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",ServerlUrl,self.model.IdentitfyBackPhotoUrl]] placeholderImage:[UIImage imageNamed:@"shangchuan"]];
                        }
                        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoPickPiture:)];
                        [cell.pictureImageView addGestureRecognizer:tap];
                        cell.pictureImageView.tag = 200 + indexPath.row;
                        return cell;
                    }
                    
                    return cell;
                }
                    break;
                    
                    
                case 1:
                {
                    LKBankFoldCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LKBankFoldCell"];
                    cell.isIdentCatogry = YES;
                    LKBankModel *bankModel = self.cellContentArray[indexPath.section][indexPath.row];
                    cell.bankModel = bankModel;
                    if ([self.headerTitle containsString:@"变更"]) {
                        if (bankModel.canEdit) {
                            cell.editBtn.hidden = NO;
                            [cell.editBtn addTarget:self action:@selector(editbankCardDetailInformation:) forControlEvents:UIControlEventTouchUpInside];
                            cell.editBtn.tag = 7000 + indexPath.row;
                        }else{
                            cell.editBtn.hidden = YES;
                        }
                    }else{
                        cell.editBtn.hidden = NO;
                        [cell.editBtn addTarget:self action:@selector(editbankCardDetailInformation:) forControlEvents:UIControlEventTouchUpInside];
                        cell.editBtn.tag = 7000 + indexPath.row;
                    }
                    [cell.arrowButton setImage:[UIImage imageNamed:@"customerDelet"] forState:UIControlStateNormal];
                    cell.arrowButton.tag = 3000 + indexPath.row;
                    [cell.arrowButton addTarget:self action:@selector(deleteBankCardInfor:) forControlEvents:UIControlEventTouchUpInside];
                    return cell;
                    
                }
                    break;
                case 2:
                {
                    LKReservePhoneNumberCell *reservcell = [tableView dequeueReusableCellWithIdentifier:@"LKReservePhoneNumberCell"];
                    reservcell.visitPhoneTf.enabled = NO;
                    reservcell.visitPhoneTf.text = self.model.DefaultTel;
                    //                UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goChooseVisitPhoneNumber:)];
                    //                [reservcell addGestureRecognizer:tap];
                    return reservcell;
                }
                    break;
                case 3:
                {
                    LKAddProtocalMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LKAddProtocalMessageCell"];
                    cell.titleLabel.text = self.cellContentArray[indexPath.section][indexPath.row];
                    cell.contentTF.tag = 20000 + indexPath.row;
                    [cell.contentTF addTarget:self action:@selector(changeSectionOneValue:) forControlEvents:UIControlEventEditingChanged];
                    cell.pictureImageView.hidden = YES;
                    cell.lineView.hidden = YES;
                    cell.arrowBtn.hidden = YES;
                    cell.bottomLineView.hidden = NO;
                    cell.mustShowStar.hidden = NO;
                    if (indexPath.row == 2)  {
                        cell.contentTF.hidden = NO;
                        cell.arrowBtn.hidden = NO;
                        cell.contentTF.enabled = NO;
                        cell.contentTF.placeholder = @"请选择";
                    }else{
                        cell.contentTF.enabled = YES;
                        cell.contentTF.hidden = NO;
                        cell.contentTF.placeholder = @"请输入";
                    }
                    switch (indexPath.row) {
                        case 0:
                        {
                            
                            cell.contentTF.text = self.model.EmergenceyName;
                            return cell;
                        }
                            break;
                        case 1:
                        {
                            
                            cell.contentTF.text = self.model.EmergenceyTel;
                            return cell;
                            
                        }
                            break;
                        case 2:
                        {
                            cell.contentTF.enabled = NO;
                            cell.contentTF.text = self.model.EmergenceyRealtion ? [self backTitleAccordingRelationType:[self.model.EmergenceyRealtion integerValue]] : @"";
                            return cell;
                        }
                            break;
                        default:
                            break;
                    }
                    return cell;
                    
                }
                    break;
                case 4:
                {
                    LKPictureDeleteOrAddCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LKPictureDeleteOrAddCell"];
                    cell.model = self.picdataArray[3];
                    __weak typeof(self) weakSelf = self;
                    [cell setPhotoViewChangeHeightBlock:^(UITableViewCell *mycell) {
                        [weakSelf.tableview reloadRowsAtIndexPaths:@[[weakSelf.tableview indexPathForCell:mycell]] withRowAnimation:0];
                    }];
                    return cell;
                }
                    break;
                    
                default:
                    break;
            }

        }else{
            switch (indexPath.section) {
                case 0:
                {
                    //根据证件的类型设置第一部分cell的展示
                    LKAddProtocalMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LKAddProtocalMessageCell"];
                    cell.mustShowStar.hidden = NO;
                    cell.titleLabel.text = self.cellContentArray[indexPath.section][indexPath.row];
                    cell.lineView.hidden = YES;
                    cell.bottomLineView.hidden = NO;
                    cell.pictureImageView.hidden = YES;
                    cell.contentTF.enabled = NO;
                    cell.contentTF.tag = 10000 + indexPath.row;
                    [cell.contentTF addTarget:self action:@selector(changeSectionOneValue:) forControlEvents:UIControlEventEditingChanged];
                    if (indexPath.row == 0 || indexPath.row == 3 || indexPath.row == 2 || indexPath.row == 5 || indexPath.row == 7) {
                        cell.arrowBtn.hidden = YES;
                        cell.contentTF.placeholder = @"请输入";
                        cell.contentTF.hidden = NO;
                        switch (indexPath.row) {
                            case 0:
                            {
                                cell.contentTF.enabled = YES;
                                cell.lineView.hidden = NO;
                                cell.contentTF.text = self.model.CustomerName;
                            }
                                break;
                            case 3:
                            {
                                cell.contentTF.enabled = YES;
                                cell.contentTF.text = self.model.Tel;
                            }
                                break;
                            case 2:
                            {
                                cell.contentTF.enabled = YES;
                                cell.contentTF.text = self.model.IdentityId;
                            }
                                break;
                            case 5:
                            {
                                cell.contentTF.enabled = YES;
                                cell.mustShowStar.hidden = YES;
                                cell.contentTF.text = self.model.Email;
                            }
                                break;
                            case 7:
                            {
                                cell.contentTF.enabled = YES;
                                cell.mustShowStar.hidden = YES;
                                cell.contentTF.text = self.model.Address;
                            }
                                break;
                                
                            default:
                                break;
                                return cell;
                        }
                        
                    }else{
                        cell.lineView.hidden = NO;
                        cell.contentTF.placeholder = @"请选择";
                        cell.contentTF.enabled = NO;
                        cell.arrowBtn.hidden = NO;
                        cell.contentTF.hidden = NO;
                        switch (indexPath.row) {
                            case 4:
                            {
                                
                                if ([self.model.CustomerGender isEqual:@"0"]) {
                                    cell.contentTF.text = @"男";
                                }else if([self.model.CustomerGender isEqual:@"1"]){
                                    cell.contentTF.text = @"女";
                                }else{
                                    cell.contentTF.text = @"";
                                }
                            }
                                break;
                            case 1:
                            {
                                cell.contentTF.text = self.model.IdentitfyCategory ? [self backTitleAccordingIdCatogaryType:[self.model.IdentitfyCategory integerValue]] :@"";
                            }
                                break;
                            case 6:
                            {
                                cell.mustShowStar.hidden = YES;
                                cell.contentTF.text = self.model.City;
                            }
                                break;
                            case 8:
                            {
                                cell.mustShowStar.hidden = YES;
                                cell.contentTF.text = self.model.Source ? [self backTitleAccordingSorceType:[self.model.Source integerValue]] : @"";
                            }
                                break;
                            default:
                                break;
                                return cell;
                        }
                        
                    }
                    if (indexPath.row == 9 || indexPath.row == 10) {
                        cell.arrowBtn.hidden = YES;
                        cell.lineView.hidden = YES;
                        cell.pictureImageView.hidden = NO;
                        cell.contentTF.hidden = YES;
                        cell.bottomLineView.hidden = YES;
                        cell.pictureImageView.userInteractionEnabled = YES;
                        if (indexPath.row == 9) {
                            [cell.pictureImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",ServerlUrl,self.model.IdentitfyPhotoUrl]] placeholderImage:[UIImage imageNamed:@"shangchuan"]];
                        }else{
                            [cell.pictureImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",ServerlUrl,self.model.IdentitfyBackPhotoUrl]] placeholderImage:[UIImage imageNamed:@"shangchuan"]];
                        }
                        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoPickPiture:)];
                        [cell.pictureImageView addGestureRecognizer:tap];
                        cell.pictureImageView.tag = 200 + indexPath.row;
                        return cell;
                    }
                    
                    return cell;            }
                    break;
                    
                    
                case 1:
                {
                    LKBankFoldCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LKBankFoldCell"];
                    LKBankModel *bankModel = self.cellContentArray[indexPath.section][indexPath.row];
                    if (bankModel.bankCardTel) {
                        cell.isIdentCatogry = YES;
                    }else{
                        cell.isIdentCatogry = NO;
                    }
                    cell.bankModel = bankModel;
                    if ([self.headerTitle containsString:@"变更"]) {
                        
                        if (bankModel.canEdit) {
                            cell.editBtn.hidden = NO;
                            [cell.editBtn addTarget:self action:@selector(editbankCardDetailInformation:) forControlEvents:UIControlEventTouchUpInside];
                            cell.editBtn.tag = 7000 + indexPath.row;
                        }else{
                            cell.editBtn.hidden = YES;
                        }
                    }else{
                        cell.editBtn.hidden = NO;
                        [cell.editBtn addTarget:self action:@selector(editbankCardDetailInformation:) forControlEvents:UIControlEventTouchUpInside];
                        cell.editBtn.tag = 7000 + indexPath.row;
                    }
                    [cell.arrowButton setImage:[UIImage imageNamed:@"customerDelet"] forState:UIControlStateNormal];
                    cell.arrowButton.tag = 3000 + indexPath.row;
                    [cell.arrowButton addTarget:self action:@selector(deleteBankCardInfor:) forControlEvents:UIControlEventTouchUpInside];
                    return cell;
                    
                }
                    break;
                case 2:
                {
                    LKAddProtocalMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LKAddProtocalMessageCell"];
                    cell.titleLabel.text = self.cellContentArray[indexPath.section][indexPath.row];
                    cell.contentTF.tag = 20000 + indexPath.row;
                    [cell.contentTF addTarget:self action:@selector(changeSectionOneValue:) forControlEvents:UIControlEventEditingChanged];
                    cell.pictureImageView.hidden = YES;
                    cell.lineView.hidden = YES;
                    cell.arrowBtn.hidden = YES;
                    cell.bottomLineView.hidden = NO;
                    cell.mustShowStar.hidden = NO;
                    if (indexPath.row == 2)  {
                        cell.contentTF.hidden = NO;
                        cell.arrowBtn.hidden = NO;
                        cell.contentTF.enabled = NO;
                        cell.contentTF.placeholder = @"请选择";
                    }else{
                        cell.contentTF.enabled = YES;
                        cell.contentTF.hidden = NO;
                        cell.contentTF.placeholder = @"请输入";
                    }
                    switch (indexPath.row) {
                        case 0:
                        {
                            
                            cell.contentTF.text = self.model.EmergenceyName;
                            return cell;
                        }
                            break;
                        case 1:
                        {
                            
                            cell.contentTF.text = self.model.EmergenceyTel;
                            return cell;
                            
                        }
                            break;
                        case 2:
                        {
                            cell.contentTF.enabled = NO;
                            cell.contentTF.text = self.model.EmergenceyRealtion ? [self backTitleAccordingRelationType:[self.model.EmergenceyRealtion integerValue]] : @"";
                            return cell;
                        }
                            break;
                        default:
                            break;
                    }
                    return cell;
                    
                }
                    break;
                case 3:
                {
                    LKPictureDeleteOrAddCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LKPictureDeleteOrAddCell"];
                    cell.model = self.picdataArray[3];
                    __weak typeof(self) weakSelf = self;
                    [cell setPhotoViewChangeHeightBlock:^(UITableViewCell *mycell) {
                        [weakSelf.tableview reloadRowsAtIndexPaths:@[[weakSelf.tableview indexPathForCell:mycell]] withRowAnimation:0];
                    }];
                    return cell;
                }
                    break;
                    
                default:
                    break;
            }

        }

    }else{
        switch (indexPath.section) {
            case 0:
            {
                //根据证件的类型设置第一部分cell的展示
                LKAddProtocalMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LKAddProtocalMessageCell"];
                cell.mustShowStar.hidden = NO;
                cell.titleLabel.text = self.cellContentArray[indexPath.section][indexPath.row];
                cell.lineView.hidden = YES;
                cell.bottomLineView.hidden = NO;
                cell.pictureImageView.hidden = YES;
                cell.contentTF.enabled = NO;
                cell.contentTF.tag = 10000 + indexPath.row;
                [cell.contentTF addTarget:self action:@selector(changeSectionOneValue:) forControlEvents:UIControlEventEditingChanged];
                if (indexPath.row == 0 || indexPath.row == 3 || indexPath.row == 2 || indexPath.row == 5 || indexPath.row == 7) {
                    cell.arrowBtn.hidden = YES;
                    cell.contentTF.placeholder = @"请输入";
                    cell.contentTF.hidden = NO;
                    switch (indexPath.row) {
                        case 0:
                        {
                            cell.contentTF.enabled = YES;
                            cell.lineView.hidden = NO;
                            cell.contentTF.text = self.model.CustomerName;
                        }
                            break;
                        case 3:
                        {
                            cell.contentTF.enabled = YES;
                            cell.contentTF.text = self.model.Tel;
                        }
                            break;
                        case 2:
                        {
                            cell.contentTF.enabled = YES;
                            cell.contentTF.text = self.model.IdentityId;
                        }
                            break;
                        case 5:
                        {
                            cell.contentTF.enabled = YES;
                            cell.mustShowStar.hidden = YES;
                            cell.contentTF.text = self.model.Email;
                        }
                            break;
                        case 7:
                        {
                            cell.contentTF.enabled = YES;
                            cell.mustShowStar.hidden = YES;
                            cell.contentTF.text = self.model.Address;
                        }
                            break;
                            
                        default:
                            break;
                            return cell;
                    }
                    
                }else{
                    cell.lineView.hidden = NO;
                    cell.contentTF.placeholder = @"请选择";
                    cell.contentTF.enabled = NO;
                    cell.arrowBtn.hidden = NO;
                    cell.contentTF.hidden = NO;
                    switch (indexPath.row) {
                        case 4:
                        {
                            
                            if ([self.model.CustomerGender isEqual:@"0"]) {
                                cell.contentTF.text = @"男";
                            }else if([self.model.CustomerGender isEqual:@"1"]){
                                cell.contentTF.text = @"女";
                            }else{
                                cell.contentTF.text = @"";
                            }
                        }
                            break;
                        case 1:
                        {
                            cell.contentTF.text = self.model.IdentitfyCategory ? [self backTitleAccordingIdCatogaryType:[self.model.IdentitfyCategory integerValue]] :@"";
                        }
                            break;
                        case 6:
                        {
                            cell.mustShowStar.hidden = YES;
                            cell.contentTF.text = self.model.City;
                        }
                            break;
                        case 8:
                        {
                            cell.mustShowStar.hidden = YES;
                            cell.contentTF.text = self.model.Source ? [self backTitleAccordingSorceType:[self.model.Source integerValue]] : @"";
                        }
                            break;
                        default:
                            break;
                            return cell;
                    }
                    
                }
                if (indexPath.row == 9 || indexPath.row == 10) {
                    cell.arrowBtn.hidden = YES;
                    cell.lineView.hidden = YES;
                    cell.pictureImageView.hidden = NO;
                    cell.contentTF.hidden = YES;
                    cell.bottomLineView.hidden = YES;
                    cell.pictureImageView.userInteractionEnabled = YES;
                    if (indexPath.row == 9) {
                        [cell.pictureImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",ServerlUrl,self.model.IdentitfyPhotoUrl]] placeholderImage:[UIImage imageNamed:@"shangchuan"]];
                    }else{
                        [cell.pictureImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",ServerlUrl,self.model.IdentitfyBackPhotoUrl]] placeholderImage:[UIImage imageNamed:@"shangchuan"]];
                    }
                    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoPickPiture:)];
                    [cell.pictureImageView addGestureRecognizer:tap];
                    cell.pictureImageView.tag = 200 + indexPath.row;
                    return cell;
                }
                
                return cell;            }
                break;
                
                
            case 1:
            {
                LKBankFoldCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LKBankFoldCell"];
                LKBankModel *bankModel = self.cellContentArray[indexPath.section][indexPath.row];
                cell.bankModel = bankModel;
                if ([self.headerTitle containsString:@"变更"]) {
                    if (bankModel.canEdit) {
                        cell.editBtn.hidden = NO;
                        [cell.editBtn addTarget:self action:@selector(editbankCardDetailInformation:) forControlEvents:UIControlEventTouchUpInside];
                        cell.editBtn.tag = 7000 + indexPath.row;
                    }else{
                        cell.editBtn.hidden = YES;
                    }
                }else{
                    cell.editBtn.hidden = NO;
                    [cell.editBtn addTarget:self action:@selector(editbankCardDetailInformation:) forControlEvents:UIControlEventTouchUpInside];
                    cell.editBtn.tag = 7000 + indexPath.row;
                }
                [cell.arrowButton setImage:[UIImage imageNamed:@"customerDelet"] forState:UIControlStateNormal];
                cell.arrowButton.tag = 3000 + indexPath.row;
                [cell.arrowButton addTarget:self action:@selector(deleteBankCardInfor:) forControlEvents:UIControlEventTouchUpInside];
                return cell;
                
            }
                break;
            case 2:
            {
                LKAddProtocalMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LKAddProtocalMessageCell"];
                cell.titleLabel.text = self.cellContentArray[indexPath.section][indexPath.row];
                cell.contentTF.tag = 20000 + indexPath.row;
                [cell.contentTF addTarget:self action:@selector(changeSectionOneValue:) forControlEvents:UIControlEventEditingChanged];
                cell.pictureImageView.hidden = YES;
                cell.lineView.hidden = YES;
                cell.arrowBtn.hidden = YES;
                cell.bottomLineView.hidden = NO;
                cell.mustShowStar.hidden = NO;
                if (indexPath.row == 2)  {
                    cell.contentTF.hidden = NO;
                    cell.arrowBtn.hidden = NO;
                    cell.contentTF.enabled = NO;
                    cell.contentTF.placeholder = @"请选择";
                }else{
                    cell.contentTF.enabled = YES;
                    cell.contentTF.hidden = NO;
                    cell.contentTF.placeholder = @"请输入";
                }
                switch (indexPath.row) {
                    case 0:
                    {
                        
                        cell.contentTF.text = self.model.EmergenceyName;
                        return cell;
                    }
                        break;
                    case 1:
                    {
                        
                        cell.contentTF.text = self.model.EmergenceyTel;
                        return cell;
                        
                    }
                        break;
                    case 2:
                    {
                        cell.contentTF.enabled = NO;
                        cell.contentTF.text = self.model.EmergenceyRealtion ? [self backTitleAccordingRelationType:[self.model.EmergenceyRealtion integerValue]] : @"";
                        return cell;
                    }
                        break;
                    default:
                        break;
                }
                return cell;
                
            }
                break;
            case 3:
            {
                LKPictureDeleteOrAddCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LKPictureDeleteOrAddCell"];
                cell.model = self.picdataArray[3];
                __weak typeof(self) weakSelf = self;
                [cell setPhotoViewChangeHeightBlock:^(UITableViewCell *mycell) {
                [weakSelf.tableview reloadRowsAtIndexPaths:@[[weakSelf.tableview indexPathForCell:mycell]] withRowAnimation:0];
                }];
                return cell;
            }
                break;
                
            default:
                break;
        }

    }
    return ListDetailcell;
}

/**
 编辑银行卡的详细信息

 */
-(void)editbankCardDetailInformation:(UIButton *)btn{
    LKAddBankCardViewController *vc = [[LKAddBankCardViewController alloc] init];
    vc.isBankCardEdit = YES;
    vc.isAutenticd = self.model.IsAuthenticated;
    vc.bankDic = self.bankListArray[btn.tag - 7000];
    WS(weakSelf)
    vc.editBankCardBlock = ^(LKAddCustomerModel *AddCustomerModel) {
        NSDictionary *bankDic = [AddCustomerModel properties_aps];
         LKAddCustomerModel *model = AddCustomerModel;
        LKBankModel *bankModel = [[LKBankModel alloc] init];
        bankModel.bankBranch = model.BankBranch;
        bankModel.bankName = model.BankName;
        bankModel.bankCity = model.BankCity;
        bankModel.accountName = model.AccountName;
        bankModel.accountCode = model.AccountCode;
        bankModel.accountPhotoUrl = model.AccountPhotoUrl;
        bankModel.bankCardTel = model.BankCardTel;
        bankModel.Id = @"0";
        bankModel.canEdit = YES;
        [weakSelf.showBankCardArray replaceObjectAtIndex:btn.tag - 7000 withObject:bankModel];
        [weakSelf.tableview reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationNone];
        NSDictionary *param;
        if ([weakSelf.model.IdentitfyCategory isEqual:@"1"]) {
            if ([model.IsAuthenticated boolValue]) {
                    param = [NSDictionary dictionaryWithObjectsAndKeys:model.BankBranch,@"BankBranch",model.BankName,@"BankName",model.BankCity,@"BankCity",model.AccountCode,@"AccountCode",model.AccountName,@"AccountName",@"0",@"Id",model.BankCardTel,@"BankCardTel",@(NO),@"IsAuthenticated",self.model.IdentitfyCategory,@"IdentitfyCategory",self.model.IdentityId,@"IdentityId", nil];
            }else{
                    param = [NSDictionary dictionaryWithObjectsAndKeys:model.BankBranch,@"BankBranch",model.BankName,@"BankName",model.BankCity,@"BankCity",model.AccountCode,@"AccountCode",model.AccountName,@"AccountName",model.AccountPhotoUrl,@"AccountPhotoUrl",@"0",@"Id",@(NO),@"IsAuthenticated", nil];
            }

        }else{
                param = [NSDictionary dictionaryWithObjectsAndKeys:model.BankBranch,@"BankBranch",model.BankName,@"BankName",model.BankCity,@"BankCity",model.AccountCode,@"AccountCode",model.AccountName,@"AccountName",model.AccountPhotoUrl,@"AccountPhotoUrl",@"0",@"Id",@(NO),@"IsAuthenticated", nil];
        }

        [weakSelf.bankListArray replaceObjectAtIndex:btn.tag - 7000 withObject:param];
        [weakSelf.tableview reloadRow:btn.tag - 7000 inSection:1 withRowAnimation:UITableViewRowAnimationNone];
    };
    NSLog(@"%@",self.bankListArray[btn.tag - 7000]);
    vc.identCatogry = self.model.IdentitfyCategory;
    [self.navigationController pushViewController:vc animated:YES];
}
/**
 删除银行卡

 */
-(void)deleteBankCardInfor:(UIButton *)btn{
    WS(weakSelf)
    UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:@"提示" message:@"确认删除该银行卡?" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *cancelaciton = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    UIAlertAction *sureciton = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [weakSelf.showBankCardArray removeObjectAtIndex:btn.tag - 3000];
        [weakSelf.bankListArray removeObjectAtIndex:btn.tag - 3000];
        [weakSelf.tableview reloadSection:1 withRowAnimation:UITableViewRowAnimationNone];
        
    }];
    [alertVc addAction:cancelaciton];
    [alertVc addAction:sureciton];
    [self presentViewController:alertVc animated:YES completion:nil];
}
/**
 textfield的文本框的输入变化

 */
-(void)changeSectionOneValue:(UITextField *)textFiled{
    if ([self.model.IdentitfyCategory isEqual:@"1"]) {
        if ([self.model.IsAuthenticated boolValue]) {
            switch (textFiled.tag) {
                case 10000:
                {
                    self.model.CustomerName = textFiled.text;
                }
                    break;
                case 10002:
                {
                    self.model.IdentityId = textFiled.text;
                    
                }
                    break;
                case 10004:
                {
                    self.model.Email = textFiled.text;
                    
                }
                    break;
                case 10006:
                {
                    self.model.Address = textFiled.text;
                    
                }
                    break;
                case 20000:
                {
                    self.model.EmergenceyName = textFiled.text;
                    
                }
                    break;
                case 20001:
                {
                    self.model.EmergenceyTel = textFiled.text;
                    
                }
                    break;
                default:
                    break;
            }
        }else{
            switch (textFiled.tag) {
                case 10000:
                {
                    self.model.CustomerName = textFiled.text;
                }
                    break;
                case 10003:
                {
                    self.model.Tel = textFiled.text;
                    
                }
                    break;
                case 10002:
                {
                    self.model.IdentityId = textFiled.text;
                    
                }
                    break;
                case 10005:
                {
                    self.model.Email = textFiled.text;
                    
                }
                    break;
                case 10007:
                {
                    self.model.Address = textFiled.text;
                    
                }
                    break;
                case 20000:
                {
                    self.model.EmergenceyName = textFiled.text;
                    
                }
                    break;
                case 20001:
                {
                    self.model.EmergenceyTel = textFiled.text;
                    
                }
                    break;
                default:
                    break;
            }
        }


    }else{
        switch (textFiled.tag) {
            case 10000:
            {
                self.model.CustomerName = textFiled.text;
            }
                break;
            case 10003:
            {
                self.model.Tel = textFiled.text;
                
            }
                break;
            case 10002:
            {
                self.model.IdentityId = textFiled.text;
                
            }
                break;
            case 10005:
            {
                self.model.Email = textFiled.text;
                
            }
                break;
            case 10007:
            {
                self.model.Address = textFiled.text;
                
            }
                break;
            case 20000:
            {
                self.model.EmergenceyName = textFiled.text;
                
            }
                break;
            case 20001:
            {
                self.model.EmergenceyTel = textFiled.text;
                
            }
                break;
            default:
                break;
        }

    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([self.model.IdentitfyCategory isEqual:@"1"]) {
        if ([self.model.IsAuthenticated boolValue]) {
            switch (indexPath.section) {
                case 0:
                {
                    if (indexPath.row == 9 || indexPath.row == 10) {
                        return 125;
                    }
                    return 65;
                }
                    break;
                case 1:
                {
                    return 200;
                }
                    break;
                case 2:
                {
                    return 65;
                }
                    break;
                case 3:
                {
                    return 65;
                }
                    break;
                case 4:
                {
                    LKPictureDeleteOrAddModel *model = self.picdataArray[3];
                    return model.cellHeight;
                }
                    break;
                default:
                    break;
            }
        }else{
            switch (indexPath.section) {
                case 0:
                {
                    if (indexPath.row == 9 || indexPath.row == 10) {
                        return 125;
                    }
                    return 65;
                }
                    break;
                case 1:
                {
                    return 240;
                }
                    break;
                case 2:
                {
                    return 65;
                }
                    break;
                case 3:
                {
                    LKPictureDeleteOrAddModel *model = self.picdataArray[3];
                    return model.cellHeight;
                }
                    break;
                default:
                    break;
            }
        }

    }else{
        switch (indexPath.section) {
            case 0:
            {
                if (indexPath.row == 9 || indexPath.row == 10) {
                    return 125;
                }
                return 65;
            }
                break;
            case 1:
            {
                return 240;
            }
                break;
            case 2:
            {
                return 65;
            }
                break;
            case 3:
            {
                LKPictureDeleteOrAddModel *model = self.picdataArray[3];
                return model.cellHeight;
            }
                break;
            default:
                break;
        }
    }

    return 0;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    WS(weakSelf)
    if ([self.model.IdentitfyCategory isEqual:@"1"]) {
        //设置头视图
        if ([self.model.IsAuthenticated boolValue]) {
            UIView *headerView = [[UIView alloc] init];
            headerView.backgroundColor = cellHeaderBgColor;
            UIView *headerBottomView = [[UIView alloc] init];
            headerBottomView.backgroundColor = [UIColor whiteColor];
            [headerView addSubview:headerBottomView];
            [headerBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.right.bottom.equalTo(headerView);
                make.height.mas_equalTo(37);
            }];
            UIImageView *iconImageView = [[UIImageView alloc] init];
            iconImageView.image = [UIImage imageNamed:self.headerIconsArray[section]];
            [headerBottomView addSubview:iconImageView];
            [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(headerBottomView).offset(14);
                make.centerY.equalTo(headerBottomView);
            }];
            LKBaseLabel *label = [LKBaseLabel labelWithFrame:CGRectZero text:@"" textColor:COLOR_HEX(0x565D66) font:[UIFont systemFontOfSize:15] textAlignment:NSTextAlignmentLeft backgroundColor:[UIColor whiteColor]];
            label.text = self.headerTitlsArray[section];
            [headerBottomView addSubview:label];
            [label mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(iconImageView.mas_right).offset(8);
                make.centerY.equalTo(iconImageView);
            }];
            if (section == 1) {
                UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                [rightBtn setTitleColor:blueDefault forState:UIControlStateNormal];
                [rightBtn setImage:[UIImage imageNamed:@"customerAdd"] forState:UIControlStateNormal];
                [rightBtn setTitle:@"  添加" forState:UIControlStateNormal];
                rightBtn.titleLabel.font = [UIFont systemFontOfSize:13];
                [headerBottomView addSubview:rightBtn];
                [rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(headerBottomView.mas_right).offset(-16);
                    make.centerY.equalTo(headerBottomView.mas_centerY);
                }];
                
                [rightBtn addTarget:self action:@selector(addBankCardVC) forControlEvents:UIControlEventTouchUpInside];
            }
            if ([self.headerTitle containsString:@"变更"]) {
                UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showOrHidden:)];
                [headerView addGestureRecognizer:tap];
            }
            headerView.tag = 100000 + section;
            return headerView;
        }else{
            //设置头视图
            UIView *headerView = [[UIView alloc] init];
            headerView.backgroundColor = cellHeaderBgColor;
            UIView *headerBottomView = [[UIView alloc] init];
            headerBottomView.backgroundColor = [UIColor whiteColor];
            [headerView addSubview:headerBottomView];
            [headerBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.right.bottom.equalTo(headerView);
                make.height.mas_equalTo(37);
            }];
            UIImageView *iconImageView = [[UIImageView alloc] init];
            iconImageView.image = [UIImage imageNamed:self.headerIconsArray[section]];
            [headerBottomView addSubview:iconImageView];
            [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(headerBottomView).offset(14);
                make.centerY.equalTo(headerBottomView);
                //            make.size.mas_equalTo(CGSizeMake(33, 24));
            }];
            LKBaseLabel *label = [LKBaseLabel labelWithFrame:CGRectZero text:@"" textColor:COLOR_HEX(0x565D66) font:[UIFont systemFontOfSize:15] textAlignment:NSTextAlignmentLeft backgroundColor:[UIColor whiteColor]];
            label.text = self.headerTitlsArray[section];
            [headerBottomView addSubview:label];
            [label mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(iconImageView.mas_right).offset(8);
                make.centerY.equalTo(iconImageView);
            }];
            if (section == 1) {
                UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                [rightBtn setTitleColor:blueDefault forState:UIControlStateNormal];
                [rightBtn setImage:[UIImage imageNamed:@"customerAdd"] forState:UIControlStateNormal];
                [rightBtn setTitle:@"  添加" forState:UIControlStateNormal];
                rightBtn.titleLabel.font = [UIFont systemFontOfSize:13];
                [headerBottomView addSubview:rightBtn];
                [rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(headerBottomView.mas_right).offset(-16);
                    make.centerY.equalTo(headerBottomView.mas_centerY);
                }];
                
                [rightBtn addTarget:self action:@selector(addBankCardVC) forControlEvents:UIControlEventTouchUpInside];
            }
            if ([self.headerTitle containsString:@"变更"]) {
                UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showOrHidden:)];
                [headerView addGestureRecognizer:tap];
            }
            headerView.tag = 100000 + section;
            return headerView;
        }

    }else{
        //设置头视图
        UIView *headerView = [[UIView alloc] init];
        headerView.backgroundColor = cellHeaderBgColor;
        UIView *headerBottomView = [[UIView alloc] init];
        headerBottomView.backgroundColor = [UIColor whiteColor];
        [headerView addSubview:headerBottomView];
        [headerBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(headerView);
            make.height.mas_equalTo(37);
        }];
        UIImageView *iconImageView = [[UIImageView alloc] init];
        iconImageView.image = [UIImage imageNamed:self.headerIconsArray[section]];
        [headerBottomView addSubview:iconImageView];
        [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(headerBottomView).offset(14);
            make.centerY.equalTo(headerBottomView);
//            make.size.mas_equalTo(CGSizeMake(33, 24));
        }];
        LKBaseLabel *label = [LKBaseLabel labelWithFrame:CGRectZero text:@"" textColor:COLOR_HEX(0x565D66) font:[UIFont systemFontOfSize:15] textAlignment:NSTextAlignmentLeft backgroundColor:[UIColor whiteColor]];
        label.text = self.headerTitlsArray[section];
        [headerBottomView addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(iconImageView.mas_right).offset(8);
            make.centerY.equalTo(iconImageView);
        }];
        if (section == 1) {
            UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            [rightBtn setTitleColor:blueDefault forState:UIControlStateNormal];
            [rightBtn setImage:[UIImage imageNamed:@"customerAdd"] forState:UIControlStateNormal];
            [rightBtn setTitle:@"  添加" forState:UIControlStateNormal];
            rightBtn.titleLabel.font = [UIFont systemFontOfSize:13];
            [headerBottomView addSubview:rightBtn];
            [rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(headerBottomView.mas_right).offset(-16);
                make.centerY.equalTo(headerBottomView.mas_centerY);
            }];
            
            [rightBtn addTarget:self action:@selector(addBankCardVC) forControlEvents:UIControlEventTouchUpInside];
        }
        if ([self.headerTitle containsString:@"变更"]) {
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showOrHidden:)];
            [headerView addGestureRecognizer:tap];
        }
        headerView.tag = 100000 + section;
        return headerView;
    }

}
-(void)showOrHidden:(UITapGestureRecognizer *)tap{
    UIView *view = tap.view;
    NSInteger section = view.tag - 100000;
    if ([self.model.IdentitfyCategory isEqual:@"1"]) {
        if ([self.model.IsAuthenticated boolValue]) {
            if (section == 0) {
                self.tmdFirstShow = !self.tmdFirstShow;
                [self.tableview reloadSection:section withRowAnimation:UITableViewRowAnimationNone];
            }else if (section == 1){
                self.tmdSecondShow= !self.tmdSecondShow;
                [self.tableview reloadSection:section withRowAnimation:UITableViewRowAnimationNone];
            }else if (section == 3){
                self.tmdThirdShow = !self.tmdThirdShow;
                [self.tableview reloadSection:section withRowAnimation:UITableViewRowAnimationNone];
            }else if(section == 4){
                self.tmdFourthShow = !self.tmdFourthShow;
                [self.tableview reloadSection:section withRowAnimation:UITableViewRowAnimationNone];
            }else{
                self.tmdlajiShow = !self.tmdlajiShow;
                [self.tableview reloadSection:section withRowAnimation:UITableViewRowAnimationNone];
            }
        }else{
            if (section == 0) {
                self.tmdFirstShow = !self.tmdFirstShow;
                [self.tableview reloadSection:section withRowAnimation:UITableViewRowAnimationNone];
            }else if (section == 1){
                self.tmdSecondShow= !self.tmdSecondShow;
                [self.tableview reloadSection:section withRowAnimation:UITableViewRowAnimationNone];
            }else if (section == 2){
                self.tmdThirdShow = !self.tmdThirdShow;
                [self.tableview reloadSection:section withRowAnimation:UITableViewRowAnimationNone];
            }else{
                self.tmdFourthShow = !self.tmdFourthShow;
                [self.tableview reloadSection:section withRowAnimation:UITableViewRowAnimationNone];
            }
        }
  
    }else{
        if (section == 0) {
            self.tmdFirstShow = !self.tmdFirstShow;
            [self.tableview reloadSection:section withRowAnimation:UITableViewRowAnimationNone];
        }else if (section == 1){
            self.tmdSecondShow= !self.tmdSecondShow;
            [self.tableview reloadSection:section withRowAnimation:UITableViewRowAnimationNone];
        }else if (section == 2){
            self.tmdThirdShow = !self.tmdThirdShow;
            [self.tableview reloadSection:section withRowAnimation:UITableViewRowAnimationNone];
        }else{
            self.tmdFourthShow = !self.tmdFourthShow;
            [self.tableview reloadSection:section withRowAnimation:UITableViewRowAnimationNone];
        }
    }

}
/**
 添加银行卡信息
 */
-(void)addBankCardVC{
    WS(weakSelf)
    LKAddBankCardViewController *vc = [[LKAddBankCardViewController alloc] init];
     vc.customeName =  self.model.CustomerName;
    vc.isAutenticd = self.model.IsAuthenticated;
    if (self.updateType) {
//        vc.model = self.model;
    }
    [vc.bankCardModel subscribeNext:^(id  _Nullable x) {
        LKAddCustomerModel *model = (LKAddCustomerModel *)x;
        weakSelf.model.BankBranch = model.BankBranch;
        weakSelf.model.BankName = model.BankName;
        weakSelf.model.BankCity = model.BankCity;
        weakSelf.model.AccountName = model.AccountName;
        weakSelf.model.AccountCode = model.AccountCode;
        weakSelf.model.AccountPhotoUrl = model.AccountPhotoUrl;
//        weakSelf.model.BankCardTel = model.BankCardTel;
        LKBankModel *bankModel = [[LKBankModel alloc] init];
        bankModel.canEdit = YES;
        bankModel.bankBranch = model.BankBranch;
        bankModel.bankName = model.BankName;
        bankModel.bankCity = model.BankCity;
        bankModel.accountName = model.AccountName;
        bankModel.accountCode = model.AccountCode;
        bankModel.accountPhotoUrl = model.AccountPhotoUrl;
        bankModel.bankCardTel = model.BankCardTel;
        bankModel.Id = @"0";
        NSString *accountCode = [NSString stringWithFormat:@"银行账户卡号：%@",model.AccountCode];
        NSString *accountName = [NSString stringWithFormat:@"户名：%@",model.AccountName];
        NSString *bankName = [NSString stringWithFormat:@"开户行：%@",model.BankName];
        NSString *bankBranch = [NSString stringWithFormat:@"开户行支行：%@",model.BankBranch];
        NSString *bankCity = [NSString stringWithFormat:@"开户行支行省市：%@",model.BankCity];
        NSString *accountPhoto = [NSString stringWithFormat:@"银行卡正面复印件：%@",@""];
        
        NSArray *selectArra = @[accountCode,accountName,bankName,bankBranch,bankCity,accountPhoto];
        [weakSelf.showBankCardArray addObject:bankModel];
        [weakSelf.tableview reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationNone];
        
        NSDictionary *param;
        if ([weakSelf.model.IdentitfyCategory isEqual:@"1"]) {
            if ([model.IsAuthenticated boolValue]) {
                param = [NSDictionary dictionaryWithObjectsAndKeys:model.BankBranch,@"BankBranch",model.BankName,@"BankName",model.BankCity,@"BankCity",model.AccountCode,@"AccountCode",model.AccountName,@"AccountName",@"0",@"Id",model.BankCardTel,@"BankCardTel",@(NO),@"IsAuthenticated",self.model.IdentitfyCategory,@"IdentitfyCategory",self.model.IdentityId,@"IdentityId", nil];
            }else{
                param = [NSDictionary dictionaryWithObjectsAndKeys:model.BankBranch,@"BankBranch",model.BankName,@"BankName",model.BankCity,@"BankCity",model.AccountCode,@"AccountCode",model.AccountName,@"AccountName",model.AccountPhotoUrl,@"AccountPhotoUrl",@(NO),@"IsAuthenticated",@"0",@"Id", nil];
            }

        }else{
            param = [NSDictionary dictionaryWithObjectsAndKeys:model.BankBranch,@"BankBranch",model.BankName,@"BankName",model.BankCity,@"BankCity",model.AccountCode,@"AccountCode",model.AccountName,@"AccountName",model.AccountPhotoUrl,@"AccountPhotoUrl",@(NO),@"IsAuthenticated",@"0",@"Id", nil];
        }
       
        [weakSelf.bankListArray addObject:param];
        
        NSLog(@"%@",weakSelf.bankListArray);
    }];
    vc.identCatogry = self.model.IdentitfyCategory;
    if (!self.model.CustomerName) {
        [SVProgressHUD showInfoWithStatus:@"请输入客户姓名"];
        return;
    }
    [self.navigationController pushViewController:vc animated:YES];
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *footerView = [[UIView alloc] init];
    footerView.backgroundColor = cellHeaderBgColor;
    return footerView;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 37;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 16;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    WS(weakSelf)
    switch (indexPath.section) {
        case 0:
            {
                if ([self.model.IdentitfyCategory isEqual:@"1"]) {
                    if ([self.model.IsAuthenticated boolValue]) {
                        switch (indexPath.row) {
                            case 3:
                            {
                                [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                                UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
                                UIAlertAction *manaciton = [UIAlertAction actionWithTitle:@"男" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                                    weakSelf.model.CustomerGender = @"0";
                                    [weakSelf.tableview reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationNone];
                                    
                                }];
                                UIAlertAction *womenaciton = [UIAlertAction actionWithTitle:@"女" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                                    weakSelf.model.CustomerGender = @"1";
                                    [weakSelf.tableview reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationNone];
                                }];
                                UIAlertAction *cancelaciton = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
                                    
                                }];
                                [alertVc addAction:manaciton];
                                [alertVc addAction:womenaciton];
                                [alertVc addAction:cancelaciton];
                                [self presentViewController:alertVc animated:YES completion:nil];
                            }
                                break;
                            case 1:
                            {
                                
                                [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                                if ([self.headerTitle isEqual:@"变更"]) {
                                    [SVProgressHUD showInfoWithStatus:@"客户变更不允许变更证件类型"];
                                    return ;
                                }
                                if (!_pickerView) {
                                    _pickerView = [[LKPickeCustomView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
                                    _pickerView.font = [UIFont systemFontOfSize:20];
                                    _pickerView.delegate = self;
                                    _pickerView.contentArray = @[@"身份证",@"护照",@"军人证件",@"港澳通行证",@"台胞证",@"营业执照",@"其他"];
                                    _pickerView.selectValue = _pickerView.contentArray[0];
                                    [_pickerView.pickView reloadAllComponents];
                                }
                                [self.view addSubview:self.pickerView];
                            }
                                break;
                                
                            case 5:
                            {
                                [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                                if (!_addpickerView) {
                                    _addpickerView = [[GFAddressPicker alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
                                    [_addpickerView updateAddressAtProvince:@"上海市" city:@"上海市" town:@"浦东新区"];
                                    _addpickerView.delegate = self;
                                    _addpickerView.font = [UIFont boldSystemFontOfSize:18];
                                }
                                [self.view addSubview:self.addpickerView];
                                [self.view bringSubviewToFront:self.addpickerView];
                            }
                                break;
                            case 7:
                            {
                                [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                                if (!_sorcepickerView) {
                                    _sorcepickerView = [[LKPickeCustomView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
                                    _sorcepickerView.font = [UIFont systemFontOfSize:20];
                                    _sorcepickerView.delegate = self;
                                    _sorcepickerView.contentArray = @[@"线下展业",@"网络媒体",@"转介绍",@"线上注册"];
                                    _sorcepickerView.selectValue = _sorcepickerView.contentArray[0];
                                    [_sorcepickerView.pickView reloadAllComponents];
                                }
                                [self.view addSubview:self.sorcepickerView];
                            }
                                break;
                            default:
                                break;
                        }
                    }else{
                        
                        switch (indexPath.row) {
                            case 4:
                            {
                                [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                                UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
                                UIAlertAction *manaciton = [UIAlertAction actionWithTitle:@"男" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                                    weakSelf.model.CustomerGender = @"0";
                                    [weakSelf.tableview reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationNone];
                                    
                                }];
                                UIAlertAction *womenaciton = [UIAlertAction actionWithTitle:@"女" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                                    weakSelf.model.CustomerGender = @"1";
                                    [weakSelf.tableview reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationNone];
                                }];
                                UIAlertAction *cancelaciton = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
                                    
                                }];
                                [alertVc addAction:manaciton];
                                [alertVc addAction:womenaciton];
                                [alertVc addAction:cancelaciton];
                                [self presentViewController:alertVc animated:YES completion:nil];
                            }
                                break;
                            case 1:
                            {

                                [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                                if ([self.headerTitle isEqual:@"变更"]) {
                                    [SVProgressHUD showInfoWithStatus:@"客户变更不允许变更证件类型"];
                                    return ;
                                }
                                if (!_pickerView) {
                                    _pickerView = [[LKPickeCustomView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
                                    _pickerView.font = [UIFont systemFontOfSize:20];
                                    _pickerView.delegate = self;
                                    _pickerView.contentArray = @[@"身份证",@"护照",@"军人证件",@"港澳通行证",@"台胞证",@"营业执照",@"其他"];
                                    _pickerView.selectValue = _pickerView.contentArray[0];
                                    [_pickerView.pickView reloadAllComponents];
                                }
                                [self.view addSubview:self.pickerView];
                            }
                                break;
                                
                            case 6:
                            {
                                [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                                if (!_addpickerView) {
                                    _addpickerView = [[GFAddressPicker alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
                                    [_addpickerView updateAddressAtProvince:@"上海市" city:@"上海市" town:@"浦东新区"];
                                    _addpickerView.delegate = self;
                                    _addpickerView.font = [UIFont boldSystemFontOfSize:18];
                                }
                                [self.view addSubview:self.addpickerView];
                                [self.view bringSubviewToFront:self.addpickerView];
                            }
                                break;
                            case 8:
                            {
                                [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                                if (!_sorcepickerView) {
                                    _sorcepickerView = [[LKPickeCustomView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
                                    _sorcepickerView.font = [UIFont systemFontOfSize:20];
                                    _sorcepickerView.delegate = self;
                                    _sorcepickerView.contentArray = @[@"线下展业",@"网络媒体",@"转介绍",@"线上注册"];
                                    _sorcepickerView.selectValue = _sorcepickerView.contentArray[0];
                                    [_sorcepickerView.pickView reloadAllComponents];
                                }
                                [self.view addSubview:self.sorcepickerView];
                            }
                                break;
                            default:
                                break;
                        }
                    }

                }else{
                    switch (indexPath.row) {
                        case 4:
                        {
                            [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                            UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
                            UIAlertAction *manaciton = [UIAlertAction actionWithTitle:@"男" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                                weakSelf.model.CustomerGender = @"0";
                                [weakSelf.tableview reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationNone];
                                
                            }];
                            UIAlertAction *womenaciton = [UIAlertAction actionWithTitle:@"女" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                                weakSelf.model.CustomerGender = @"1";
                                [weakSelf.tableview reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationNone];
                            }];
                            UIAlertAction *cancelaciton = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
                                
                            }];
                            [alertVc addAction:manaciton];
                            [alertVc addAction:womenaciton];
                            [alertVc addAction:cancelaciton];
                            [self presentViewController:alertVc animated:YES completion:nil];
                        }
                            break;
                        case 1:
                        {
                            [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                            if ([self.headerTitle isEqual:@"变更"]) {
                                [SVProgressHUD showInfoWithStatus:@"客户变更不允许变更证件类型"];
                                return ;
                            }
                            if (!_pickerView) {
                                _pickerView = [[LKPickeCustomView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
                                _pickerView.font = [UIFont systemFontOfSize:20];
                                _pickerView.delegate = self;
                                _pickerView.contentArray = @[@"身份证",@"护照",@"军人证件",@"港澳通行证",@"台胞证",@"营业执照",@"其他"];
                                _pickerView.selectValue = _pickerView.contentArray[0];
                                [_pickerView.pickView reloadAllComponents];
                            }
                            [self.view addSubview:self.pickerView];
                        }
                            break;
                            
                        case 6:
                        {
                            [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                            if (!_addpickerView) {
                                _addpickerView = [[GFAddressPicker alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
                                [_addpickerView updateAddressAtProvince:@"上海市" city:@"上海市" town:@"浦东新区"];
                                _addpickerView.delegate = self;
                                _addpickerView.font = [UIFont boldSystemFontOfSize:18];
                            }
                            [self.view addSubview:self.addpickerView];
                            [self.view bringSubviewToFront:self.addpickerView];
                        }
                            break;
                        case 8:
                        {
                            [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                            if (!_sorcepickerView) {
                                _sorcepickerView = [[LKPickeCustomView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
                                _sorcepickerView.font = [UIFont systemFontOfSize:20];
                                _sorcepickerView.delegate = self;
                                _sorcepickerView.contentArray = @[@"线下展业",@"网络媒体",@"转介绍",@"线上注册"];
                                _sorcepickerView.selectValue = _sorcepickerView.contentArray[0];
                                [_sorcepickerView.pickView reloadAllComponents];
                            }
                            [self.view addSubview:self.sorcepickerView];
                        }
                            break;
                        default:
                            break;
                    }
                }

            }
            break;
        case 1:
        {
            
        }
            break;
        case 2:
        {
            if ([self.model.IdentitfyCategory isEqual:@"1"]) {
                if ([self.model.IsAuthenticated boolValue]) {
                    [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                    _visitPhoneView = [[LKPickeCustomView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
                    _visitPhoneView.font = [UIFont systemFontOfSize:20];
                    _visitPhoneView.delegate = self;
                    NSMutableArray *arra = [[NSMutableArray alloc] init];
                    for (NSDictionary *param in self.bankListArray) {
                        if (param[@"BankCardTel"]) {
                            [arra addObject:param[@"BankCardTel"]];
                        }
                    }
                    _visitPhoneView.contentArray = arra;
                    if (arra.count == 0) {
                        
                    }else{
                        _visitPhoneView.selectValue = _visitPhoneView.contentArray[0];
                    }
                    [_visitPhoneView.pickView reloadAllComponents];
                    [self.view addSubview:self.visitPhoneView];
                }else{
                    if (indexPath.row == 2) {
                        [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                        if (!_relationView) {
                            _relationView = [[LKPickeCustomView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
                            _relationView.font = [UIFont systemFontOfSize:20];
                            _relationView.delegate = self;
                            _relationView.contentArray = @[@"家人",@"朋友",@"同事",@"其他"];
                            _relationView.selectValue = _relationView.contentArray[0];
                            [_relationView.pickView reloadAllComponents];
                        }
                        [self.view addSubview:self.relationView];
                    }
                }

            }else{
                if (indexPath.row == 2) {
                    [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                    if (!_relationView) {
                        _relationView = [[LKPickeCustomView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
                        _relationView.font = [UIFont systemFontOfSize:20];
                        _relationView.delegate = self;
                        _relationView.contentArray = @[@"家人",@"朋友",@"同事",@"其他"];
                        _relationView.selectValue = _relationView.contentArray[0];
                        [_relationView.pickView reloadAllComponents];
                    }
                    [self.view addSubview:self.relationView];
                }
            }

        }
            break;
        case 3:
        {
            if (![self.model.IdentitfyCategory isEqual:@"1"]) {
                
            }else{
                if ([self.model.IsAuthenticated boolValue]) {
                    if (indexPath.row == 2) {
                        [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                        if (!_relationView) {
                            _relationView = [[LKPickeCustomView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
                            _relationView.font = [UIFont systemFontOfSize:20];
                            _relationView.delegate = self;
                            _relationView.contentArray = @[@"家人",@"朋友",@"同事",@"其他"];
                            _relationView.selectValue = _relationView.contentArray[0];
                            [_relationView.pickView reloadAllComponents];
                        }
                        [self.view addSubview:self.relationView];
                    }
                }else{
                    
                }

            }
        }
            break;
        case 4:
        {
            
        }
            break;
        default:
            break;
    }
}
#pragma mark -地址选择器的代理方法
- (void)GFAddressPickerCancleAction
{
    [self.addpickerView removeFromSuperview];
}

- (void)GFAddressPickerWithProvince:(NSString *)province
                               city:(NSString *)city area:(NSString *)area
{
    if ([self.model.IdentitfyCategory isEqual:@"1"]) {
        if ([self.model.IsAuthenticated boolValue]) {
            LKAddProtocalMessageCell *cell = (LKAddProtocalMessageCell *)[self.tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:5 inSection:0]];
            self.model.City = [NSString stringWithFormat:@"%@/%@/%@",province,city,area];
            cell.contentTF.text = self.model.City;
            [self.addpickerView removeFromSuperview];
        }else{
            LKAddProtocalMessageCell *cell = (LKAddProtocalMessageCell *)[self.tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:6 inSection:0]];
            self.model.City = [NSString stringWithFormat:@"%@/%@/%@",province,city,area];
            cell.contentTF.text = self.model.City;
            [self.addpickerView removeFromSuperview];
        }

    }else{
        LKAddProtocalMessageCell *cell = (LKAddProtocalMessageCell *)[self.tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:6 inSection:0]];
        self.model.City = [NSString stringWithFormat:@"%@/%@/%@",province,city,area];
        cell.contentTF.text = self.model.City;
        [self.addpickerView removeFromSuperview];
    }

}
#pragma 自定义选择器的值选择

/**
 获取选择的到值

 */
-(void)getContentInformation:(NSString *)sex AndPickerView:(UIPickerView *)pickeView{
    if ([pickeView isEqual:self.pickerView.pickView]) {
        LKAddProtocalMessageCell *cell = (LKAddProtocalMessageCell *)[self.tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]];
        cell.contentTF.text = sex;
//        self.model = [[LKAddCustomerModel alloc] init];
//            __block LKPictureDeleteOrAddModel *model = self.picdataArray[3];
//        [model.endSelectedList removeAllObjects];
//        [self.showBankCardArray removeAllObjects];
//        [self.bankListArray removeAllObjects];
        NSString *compareStr = [NSString stringWithFormat:@"%ld",[self backIDCatogaryTypeAccordingTitle:sex]];
        self.model.IdentitfyCategory = [NSString stringWithFormat:@"%ld",[self backIDCatogaryTypeAccordingTitle:sex]];
        [self.pickerView removeFromSuperview];
        if ([self.model.IdentitfyCategory isEqual:@"1"]) {
            if ([self.model.IsAuthenticated boolValue]) {
                self.cellContentArray = [[NSMutableArray alloc] initWithArray:@[@[@"姓名：",@"证件类型：",@"证件号码：",@"性别：",@"邮箱：",@"所在地区：",@"详细地址：",@"来源："],self.showBankCardArray,@[@""],@[@"姓名：",@"电话：",@"关系："],@[@""]]];
                self.headerTitlsArray = @[@"基本信息",@"银行信息",@"默认回访手机号",@"紧急联系人",@"附件信息"];
                self.headerIconsArray = @[@"xieyixinxi",@"yinhangxinxi",@"defautVistiPhone",@"customerHeaderIcon",@"fujian"];
            }else{
                self.cellContentArray = [[NSMutableArray alloc] initWithArray:@[@[@"姓名：",@"证件类型：",@"证件号码：",@"电话：",@"性别：",@"邮箱：",@"所在地区：",@"详细地址：",@"来源：",@"证件附件正面：",@"证件附件反面："],self.showBankCardArray,@[@"姓名：",@"电话：",@"关系："],@[@""]]];
                self.headerTitlsArray = @[@"基本信息",@"银行信息",@"紧急联系人",@"附件信息"];
                self.headerIconsArray = @[@"xieyixinxi",@"yinhangxinxi",@"customerHeaderIcon",@"fujian"];
            }

        }else{
            self.cellContentArray = [[NSMutableArray alloc] initWithArray:@[@[@"姓名：",@"证件类型：",@"证件号码：",@"电话：",@"性别：",@"邮箱：",@"所在地区：",@"详细地址：",@"来源：",@"证件附件正面：",@"证件附件反面："],self.showBankCardArray,@[@"姓名：",@"电话：",@"关系："],@[@""]]];
            self.headerTitlsArray = @[@"基本信息",@"银行信息",@"紧急联系人",@"附件信息"];
            self.headerIconsArray = @[@"xieyixinxi",@"yinhangxinxi",@"customerHeaderIcon",@"fujian"];
        }
        [self.tableview reloadData];
    }else if([pickeView isEqual:self.sorcepickerView.pickView]){
        if ([self.model.IdentitfyCategory isEqual:@"1"]) {
            if ([self.model.IsAuthenticated boolValue]) {
                LKAddProtocalMessageCell *cell = (LKAddProtocalMessageCell *)[self.tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:7 inSection:0]];
                cell.contentTF.text = sex;
                self.model.Source = [NSString stringWithFormat:@"%ld",[self backTypeAccordingSorceTile:sex]];
                [self.sorcepickerView removeFromSuperview];
            }else{
                LKAddProtocalMessageCell *cell = (LKAddProtocalMessageCell *)[self.tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:8 inSection:0]];
                cell.contentTF.text = sex;
                self.model.Source = [NSString stringWithFormat:@"%ld",[self backTypeAccordingSorceTile:sex]];
                [self.sorcepickerView removeFromSuperview];
            }

        }else{
            LKAddProtocalMessageCell *cell = (LKAddProtocalMessageCell *)[self.tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:8 inSection:0]];
            cell.contentTF.text = sex;
            self.model.Source = [NSString stringWithFormat:@"%ld",[self backTypeAccordingSorceTile:sex]];
            [self.sorcepickerView removeFromSuperview];
        }

    }else if([pickeView isEqual:self.relationView.pickView]){
        if ([self.model.IdentitfyCategory isEqual:@"1"]) {
            if ([self.model.IsAuthenticated boolValue]) {
                LKAddProtocalMessageCell *cell = (LKAddProtocalMessageCell *)[self.tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:3]];
                cell.contentTF.text = sex;
                self.model.EmergenceyRealtion = [NSString stringWithFormat:@"%ld",[self backRelationTypeAccordingTitle:sex]];
                [self.relationView removeFromSuperview];
            }else{
                LKAddProtocalMessageCell *cell = (LKAddProtocalMessageCell *)[self.tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:2]];
                cell.contentTF.text = sex;
                self.model.EmergenceyRealtion = [NSString stringWithFormat:@"%ld",[self backRelationTypeAccordingTitle:sex]];
                [self.relationView removeFromSuperview];
            }
 
        }else{
            LKAddProtocalMessageCell *cell = (LKAddProtocalMessageCell *)[self.tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:2]];
            cell.contentTF.text = sex;
            self.model.EmergenceyRealtion = [NSString stringWithFormat:@"%ld",[self backRelationTypeAccordingTitle:sex]];
            [self.relationView removeFromSuperview];
        }

    }else{
        LKReservePhoneNumberCell *cell = [self.tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:2]];
        cell.visitPhoneTf.text = sex;
        self.model.DefaultTel = sex;
        [self.visitPhoneView removeFromSuperview];
    }

}

/**
 取消的代理放啊
 */
-(void)ContentPickerCancleActionAndPickerView:(UIPickerView *)pickeView{
    if ([pickeView isEqual:self.pickerView.pickView]) {
        [self.pickerView removeFromSuperview];
    }else if ([pickeView isEqual:self.sorcepickerView.pickView]){
        [self.sorcepickerView removeFromSuperview];
    }else if([pickeView isEqual:self.relationView.pickView]){
        [self.relationView removeFromSuperview];
    }else{
        [self.visitPhoneView removeFromSuperview];
    }
    
}
-(void)gotoPickPiture:(UITapGestureRecognizer *)tap{
    [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
    UIView *view = tap.view;
    self.selectValue = view.tag;
    //             判断是否支持相机
    if(![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
        [SVProgressHUD showInfoWithStatus:@"无法使用相机"];
        return;
    }
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    NSUInteger sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    [self camerOrAlbumsPhotoChooseWithAlert:alert AndSourceType:sourceType];
    [self presentViewController:alert animated:YES completion:nil];
}
/**
 从相册或者相机中选择图片
 
 @param alert 弹框
 @param sourceTypea 相机或者相册
 */
-(void)camerOrAlbumsPhotoChooseWithAlert:(UIAlertController *)alert AndSourceType:(NSInteger) sourceTypea{
    __block NSInteger sourceType = sourceTypea;
    [alert addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        //来源:相机
        sourceType = UIImagePickerControllerSourceTypeCamera;
        // 跳转到相机或相册页面
        UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
        imagePickerController.delegate = (id)self;
        imagePickerController.allowsEditing = NO;
        imagePickerController.sourceType = sourceType;
        imagePickerController.transitioningDelegate = self;
        imagePickerController.modalPresentationStyle = UIModalPresentationCustom;
        [self presentViewController:imagePickerController animated:YES completion:nil];
        
    }]];
    [alert addAction:[UIAlertAction actionWithTitle:@"从相册选取" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        //来源:相册
        sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        // 跳转到相机或相册页面
        UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
        imagePickerController.delegate = (id)self;
        imagePickerController.allowsEditing = NO;
        imagePickerController.navigationBar.translucent = NO;
        [imagePickerController.navigationBar setBarTintColor:blueDefault];
        imagePickerController.sourceType = sourceType;
        imagePickerController.transitioningDelegate = self;
        imagePickerController.modalPresentationStyle = UIModalPresentationCustom;
        [self presentViewController:imagePickerController animated:YES completion:nil];
        
    }]];
    [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
    }]];
}
#pragma mark - 调用相机的代理方法
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
    [self dismissViewControllerAnimated:YES completion:nil];
    WS(weakSelf)
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
    LKAddProtocalMessageCell *cell = [_tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:self.selectValue - 200 inSection:0]];
    UIImage *aimage = image;
    cell.pictureImageView.image = aimage;
    if (self.selectValue == 209) {
        self.model.IdentitfyPhoto = aimage;
        [[LKNetDataManager defaultManager] sendPOSTRequestWithserverUrl:ServerlUrl apiPath:otherOfPictureUrl parameters:nil imageArray:@[aimage] targetWidth:100 progress:^(NSProgress * _Nullable progress) {
            
        } success:^(BOOL isSuccess, id  _Nullable responseObject) {
            weakSelf.model.IdentitfyPhotoUrl = responseObject[@"fileUrl"];
        } failure:^(NSString * _Nullable error) {
            
        }];
    }else if(self.selectValue == 210){
        self.model.IdentitfyBackPhotoUrl = @"身份证反面";
        self.model.IdentitfyBackPhoto = aimage;
        [[LKNetDataManager defaultManager] sendPOSTRequestWithserverUrl:ServerlUrl apiPath:otherOfPictureUrl parameters:nil imageArray:@[aimage] targetWidth:100 progress:^(NSProgress * _Nullable progress) {
            
        } success:^(BOOL isSuccess, id  _Nullable responseObject) {
            weakSelf.model.IdentitfyBackPhotoUrl = responseObject[@"fileUrl"];
        } failure:^(NSString * _Nullable error) {
            
        }];
    }else{
        LKWorkOrderDetailContractCell *cell = [_tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:self.selectValue - 300 inSection:3]];
        cell.iconImageView.image = aimage;
        self.model.CustomerAttach = @"附件";
        self.model.AttachImage = aimage;
    }

}
//缩放图片到指定大小的imageview
- (UIImage*)imageCompressWithSimple:(UIImage*)image scaledToSize:(CGSize)size
{
    UIGraphicsBeginImageContext(size);
    [image drawInRect:CGRectMake(0,0,size.width,size.height)];
    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newImage;
}

//-(NSMutableArray *)cellContentArray{
//    if (!_cellContentArray) {
//
//        _cellContentArray = [[NSMutableArray alloc] initWithArray:@[@[@"姓名：",@"证件类型：",@"证件号码：",@"电话：",@"性别：",@"邮箱：",@"所在地区：",@"详细地址：",@"来源：",@"证件附件正面：",@"证件附件反面："],self.showBankCardArray,@[@"姓名：",@"电话：",@"关系："],@[@""]]];
//    }
//    return _cellContentArray;
//}


//-(NSArray *)headerTitlsArray{
//    if (!_headerTitlsArray) {
//        _headerTitlsArray = @[@"基本信息",@"银行信息",@"紧急联系人",@"附件信息"];
//    }
//    return _headerTitlsArray;
//}
//-(NSArray *)headerIconsArray{
//    if (!_headerIconsArray) {
//        _headerIconsArray = @[@"xieyixinxi",@"yinhangxinxi",@"customerHeaderIcon",@"fujian"];
//    }
//    return _headerIconsArray;
//}

/**
 根据标题转化为来源类型

 @param title 标题
 @return 类型值
 */
-(NSInteger)backTypeAccordingSorceTile:(NSString *)title{
    if ([title isEqual:@"线下展业"]) {
        return 1;
    }else if ([title isEqual:@"网络媒体"]){
        return 2;
    }else if ([title isEqual:@"转介绍"]){
        return 3;
    }
    return 4;
}

/**
 根据类型转化为文字

 @param type 类型值
 @return 标题
 */
-(NSString *)backTitleAccordingSorceType:(NSInteger )type{
    if (type == 1) {
        return @"线下展业";
    }else if (type == 2){
        return @"网络媒体";
    }else if (type == 3){
        return @"转介绍";
    }
    return @"线上注册";
}

/**
 根据关系文字返回类型

 @param title 关系文字
 @return 类型
 */
-(NSInteger)backRelationTypeAccordingTitle:(NSString *)title{
    if ([title isEqual:@"家人"]) {
        return 1;
    }else if ([title isEqual:@"朋友"]){
        return 2;
    }else if ([title isEqual:@"同事"]){
        return 3;
    }
    return 4;
}
/**
 根据关系类型返回文字

 @param type 类型
 @return 文字
 */
-(NSString *)backTitleAccordingRelationType:(NSInteger)type{
    if (type == 1) {
        return @"家人";
    }else if (type == 2){
        return @"朋友";
    }else if (type == 3){
        return @"同事";
    }
    return @"其他";
}

/**
 根据文字返回证件类型

 @param title 标题
 @return 类型
 */
-(NSInteger)backIDCatogaryTypeAccordingTitle:(NSString *)title{
    if ([title isEqual:@"身份证"]) {
        return 1;
    }else if ([title isEqual:@"护照"]){
        return 2;
    }else if ([title isEqual:@"军人证件"]){
        return 3;
    }else if ([title isEqual:@"港澳通行证"]){
        return 4;
    }else if ([title isEqual:@"台胞证"]){
        return 5;
    }else if ([title isEqual:@"营业执照"]){
        return 6;
    }
    return 7;
}
/**
 根据证件类型返回文字

 @param type 证件类型
 @return 文字
 */
-(NSString *)backTitleAccordingIdCatogaryType:(NSInteger)type{
    if (type == 1) {
        return @"身份证";
    }else if (type == 2){
        return @"护照";
    }else if (type == 3){
        return @"军人证件";
    }else if (type == 4){
        return @"港澳通行证";
    }else if (type == 5){
        return @"台胞证";
    }else if (type == 6){
        return @"营业执照";
    }
    return @"其他";
}
-(NSMutableArray *)bankListArray{
    if (!_bankListArray) {
        _bankListArray = [[NSMutableArray alloc] init];
    }
    return _bankListArray;
}
-(NSMutableArray *)showBankCardArray{
    if (!_showBankCardArray) {
        _showBankCardArray = [[NSMutableArray alloc] init];
    }
    return _showBankCardArray;
}
-(NSMutableArray *)attachsArray{
    if (!_attachsArray) {
        _attachsArray = [[NSMutableArray alloc] init];
    }
    return _attachsArray;
}
-(NSMutableArray *)uploadImageArray{
    if (!_uploadImageArray) {
        _uploadImageArray = [[NSMutableArray alloc] init];
    }
    return _uploadImageArray;
}
/**
 获取需要更新的用户的详细信息
 */
-(void)getUpdateModelInformation{
    NSString *customerCode;
    NSString *chooseurl;
    NSDictionary *param;
    if (self.isOrderUpdate) {
        customerCode = self.addOrderModel.CustomerCode;
        param = @{@"Id":self.addOrderModel.CustomerId};
        if ([self.headerTitle containsString:@"变更"]) {
            chooseurl = changeUpdateDetailUrl;
        }else{
            chooseurl = editUserDetailUrl;
        }
    }else{
         customerCode = _updateModel.customerCode;
        if ([self.headerTitle containsString:@"变更"]) {
            chooseurl = changeUpdateDetailUrl;
            param = @{@"Id":_updateModel.customerId};
        }else{
            chooseurl = editUserDetailUrl;
            param = @{@"Id":_updateModel.customerId};
        }
    }
    [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:chooseurl header:[LKUserInforTool header] parameters:param progress:^(NSProgress * _Nullable progress) {
        
    } success:^(BOOL isSuccess, id  _Nullable responseObject) {
        NSDictionary *dic = responseObject[@"result"];
        LKCustomerModel *model = [LKCustomerModel modelWithDictionary:dic];
        self.updateModel = model;
        self.model.Email = model.email;
        self.model.CustomerName = model.customerName;
         self.model.Tel = model.tel;
         self.model.IdentityId = model.identityId;
        self.model.IdentitfyCategory = model.identitfyCategory;
         self.model.Email = model.email;
         self.model.Address = model.address;
         self.model.EmergenceyName = model.emergenceyName;
        self.model.EmergenceyTel = model.emergenceyTel;
        self.model.BankCards = model.bankCards;
        self.model.CustomerCode = model.customerCode;
        self.model.CustomerGender = model.customerGender;
        self.model.CustormerCategory = model.custormerCategory;
        self.model.EmergenceyRealtion = model.emergenceyRealtion;
        self.model.City = model.city;
        self.model.Version = model.version;
        self.model.Source = model.source;
        self.model.IdentitfyBackPhotoUrl = model.identitfyBackPhotoUrl;
        self.model.IdentitfyPhotoUrl = model.identitfyPhotoUrl;
        self.model.DefaultTel = model.defaultTel;
        self.model.IsAuthenticated = model.isAuthenticated;
        [self.showBankCardArray addObjectsFromArray:model.bankCards];
        for (LKBankModel *bankModel in model.bankCards) {
            NSDictionary *mutableDic = [bankModel properties_aps];
            NSArray *keysValue = [mutableDic allKeys];
            NSMutableDictionary *newSetDic = [NSMutableDictionary dictionary];
            for (NSInteger i = 0; i < keysValue.count; i++) {
                NSString *key = keysValue[i];
                NSLog(@"键%@",key);
                if ([key isEqual:@"Id"]) {
                    NSDictionary *newDic = [NSDictionary dictionaryWithObject:[mutableDic objectForKey:key] forKey:key];
                    [newSetDic addEntriesFromDictionary:newDic];
                    continue ;
                }
                if ([key isEqual:@"isAuthenticated"]) {
                    NSString *value = [mutableDic objectForKey:@"isAuthenticated"];
                    BOOL valueBool = [value boolValue];
                    NSDictionary *newDic = [NSDictionary dictionaryWithObject:@(valueBool) forKey:@"isAuthenticated"];
                    [newSetDic addEntriesFromDictionary:newDic];
                    continue;
                }
                NSString *value = [mutableDic objectForKey:key];
                NSLog(@"值%@",value);
                char headTitle = [key characterAtIndex:0] - 32;
                NSRange range = NSMakeRange(0, 1);
                key = [key stringByReplacingCharactersInRange:range withString:[NSString stringWithFormat:@"%c",headTitle]];
                NSDictionary *newDic = [NSDictionary dictionaryWithObject:value forKey:key];
                [newSetDic addEntriesFromDictionary:newDic];
            }
            [self.bankListArray addObject:newSetDic];
        }
        
        for (LKCustomerDetailAttachModel *attachModel in model.customerAttach) {
            UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",ServerlUrl,attachModel.attachUrl]]]];
            if (image == nil) {
                image = [UIImage imageNamed:@"pic"];
            }
            [self.attachsArray addObject:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",ServerlUrl,attachModel.attachUrl]]];
        }
        LKPictureDeleteOrAddModel *endseleModel = self.picdataArray[3];
        NSMutableArray *foreImages = [[NSMutableArray alloc] init];
        
        for (NSURL *urlStr in self.attachsArray) {
            NSData *data = [NSData dataWithContentsOfURL:urlStr];
            if (data == nil) {
                HXPhotoModel *model = [HXPhotoModel photoModelWithImage:[UIImage imageNamed:@"shangchuan"]];
                [foreImages addObject:model];
            }else{
                HXPhotoModel *model = [HXPhotoModel photoModelWithImageURL:urlStr];
                [foreImages addObject:model];
            }

        }
        
        endseleModel.endSelectedList = foreImages.mutableCopy;
        
        if ([self.model.IdentitfyCategory isEqual:@"1"]) {
            if ([self.model.IsAuthenticated boolValue]) {
                self.cellContentArray = [[NSMutableArray alloc] initWithArray:@[@[@"姓名：",@"证件类型：",@"证件号码：",@"性别：",@"邮箱：",@"所在地区：",@"详细地址：",@"来源："],self.showBankCardArray,@[@""],@[@"姓名：",@"电话：",@"关系："],@[@""]]];
                self.headerTitlsArray = @[@"基本信息",@"银行信息",@"默认回访手机号",@"紧急联系人",@"附件信息"];
                self.headerIconsArray = @[@"xieyixinxi",@"yinhangxinxi",@"defautVistiPhone",@"customerHeaderIcon",@"fujian"];
            }else{
                self.cellContentArray = [[NSMutableArray alloc] initWithArray:@[@[@"姓名：",@"证件类型：",@"证件号码：",@"电话：",@"性别：",@"邮箱：",@"所在地区：",@"详细地址：",@"来源：",@"证件附件正面：",@"证件附件反面："],self.showBankCardArray,@[@"姓名：",@"电话：",@"关系："],@[@""]]];
                self.headerTitlsArray = @[@"基本信息",@"银行信息",@"紧急联系人",@"附件信息"];
                self.headerIconsArray = @[@"xieyixinxi",@"yinhangxinxi",@"customerHeaderIcon",@"fujian"];
            }

        }else{
            self.cellContentArray = [[NSMutableArray alloc] initWithArray:@[@[@"姓名：",@"证件类型：",@"证件号码：",@"电话：",@"性别：",@"邮箱：",@"所在地区：",@"详细地址：",@"来源：",@"证件附件正面：",@"证件附件反面："],self.showBankCardArray,@[@"姓名：",@"电话：",@"关系："],@[@""]]];
            self.headerTitlsArray = @[@"基本信息",@"银行信息",@"紧急联系人",@"附件信息"];
            self.headerIconsArray = @[@"xieyixinxi",@"yinhangxinxi",@"customerHeaderIcon",@"fujian"];
        }
        [self.tableview reloadData];
//        [self.tableview reloadData];
        
        
    } failure:^(NSString * _Nullable errorMessage) {
        
    }];
}
/**
 取消上传变更附件
 */
-(void)dismissTheUpLoadBgView:(UIButton *)btn{
    [self.uploadBgView removeFromSuperview];
}

/**
 上传变更附件并获取信息
 
 */
-(void)uploadChangeFileAction:(UIButton *)btn{
    [self.uploadBgView removeFromSuperview];
    NSLog(@"图片信息%@",self.uploadChangeFileView.imageList);
    for (NSInteger i = 0; i < self.uploadChangeFileView.imageList.count; i++) {
        UIImage *image = self.uploadChangeFileView.imageList[i];
        [[LKNetDataManager defaultManager] sendPOSTRequestWithserverUrl:ServerlUrl apiPath:orderOfPictureUrl parameters:nil imageArray:@[image] targetWidth:100 progress:^(NSProgress * _Nullable progress) {
            
        } success:^(BOOL isSuccess, id  _Nullable responseObject) {
            LKCustomerAttachModel *attachModel = [[LKCustomerAttachModel alloc] init];
            attachModel.AttachName = responseObject[@"fileName"];
            attachModel.AttachUrl = responseObject[@"fileUrl"];
            attachModel.Suffix = responseObject[@"suffix"];
            attachModel.OrderAttachCategory = @"0";
            NSDictionary *dic = [attachModel properties_aps];
            [self.customerAttachsChangeArray addObject:dic];
            if (self.customerAttachsChangeArray.count == self.uploadChangeFileView.imageList.count) {
                self.waitSignal = NO;
                [self addAndSaveCustomerInformation:nil];
            }
        } failure:^(NSString * _Nullable error) {
            
        }];
    }
    
    
}
-(NSMutableArray *)customerAttachsChangeArray{
    if (!_customerAttachsChangeArray) {
        _customerAttachsChangeArray = [[NSMutableArray alloc] init];
    }
    return _customerAttachsChangeArray;
    
}

/**
 观察Model的类型

 @param observer 客户Model
 @param keyPath 身份证类型
 @param options 值得改变
 @param context 无
 */
//-(void)addObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath options:(NSKeyValueObservingOptions)options context:(void *)context{
//    if ([keyPath isEqual:@"IdentitfyCategory"]) {
//        [self.tableview reloadData];
//    }
//}
//-(void)dealloc{
//    [self.model removeObserver:self forKeyPath:@"IdentitfyCategory"];
//}
/**
 根据变更或者编辑状态更新updateModel
 */
-(void)accordingStatusuPdateModel{
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
